﻿@model IEnumerable<ConsoleApplication2.Models.Operations>

@{
    ViewBag.Title = "Index";
}


    <select id="multiple" multiple="multiple">
        @foreach (var item in Model)
        {


            <option value="@Html.DisplayFor(modelItem => item.ID)_@Html.DisplayFor(modelItem => item.Duration)" selected=" selected">@Html.DisplayFor(modelItem => item.Arabic)
        -
                @Html.DisplayFor(modelItem => item.Duration)
        رقايق
        
        </option>


        }
    </select>
<input id="shit" type="text" name="fname"><br>

<script>
    function displayVals() {
 
        var multipleValues = $("#multiple").val();
        var sum = 0;
        for (var i = 0, l = multipleValues.length; i < l; i++) {
            sum += parseInt(multipleValues[i].split("_")[1], 10);
        }
        $("#shit").val(sum);
    }

    $("select").change(displayVals);
    displayVals();
</script>
